package com.job.Yangmingyu.Zuoye0714;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

/**
 * @author com.job.Yangmingyu
 * @version 1.0
 * @since 2022-07-14 20:28:20
 */
public class Usebig {
    public static void main(String[] args) {
        double d1=2.0,d2=1.1;
        System.out.println(d1-d2);

        BigDecimal b1=new BigDecimal("20.15651651651666133032");
        //大数字 不能使用普通算术运算 使用方法运算
        BigDecimal b2=new BigDecimal("2.15651651651666133032453435445245345434343535343");

        BigDecimal result=b1.divide(b2, 30, RoundingMode.HALF_UP);
        System.out.println(result.toString());

        BigDecimal b3=new BigDecimal(3.14);
        BigDecimal multiply=b1.multiply(b3,new MathContext(30,RoundingMode.HALF_UP));
        System.out.println(multiply);
        
        BigDecimal multiply2=b1.multiply(b3);
        multiply2=multiply2.setScale(30, RoundingMode.HALF_UP);
        System.out.println(multiply2);
    }
}